package cn.iocoder.yudao.module.crm.dal.mysql.performance.config;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crm.controller.admin.performance.config.vo.PerformanceConfigPageReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.performance.config.PerformanceConfigDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * CRM_业绩配置 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface PerformanceConfigMapper extends BaseMapperX<PerformanceConfigDO> {

    default PageResult<PerformanceConfigDO> selectPage(PerformanceConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PerformanceConfigDO>()
                .eqIfPresent(PerformanceConfigDO::getYear, reqVO.getYear())
                .eqIfPresent(PerformanceConfigDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(PerformanceConfigDO::getPerformancePoint, reqVO.getPerformancePoint())
                .orderByDesc(PerformanceConfigDO::getYear)
                .orderByDesc(PerformanceConfigDO::getDeptId));
    }

    default List<PerformanceConfigDO> selectList(PerformanceConfigPageReqVO pageReqVO){
        return selectList(new LambdaQueryWrapperX<PerformanceConfigDO>()
                .eqIfPresent(PerformanceConfigDO::getYear, pageReqVO.getYear())
                .eqIfPresent(PerformanceConfigDO::getDeptId, pageReqVO.getDeptId())
                .eqIfPresent(PerformanceConfigDO::getPerformancePoint, pageReqVO.getPerformancePoint()));
    }
}